﻿using B.S.DataBase.MyProject.ErrorCode;
using MediatR;
using MedicalPCTerminal.Write.API.Appcation.Commands.ChronicCareCommand;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace MedicalPCTerminal.Write.API.Controllers
{
   /// <summary>
   /// 慢病诊疗的控制器-写
   /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ChronicCareController : ControllerBase
    {
        /// <summary>
        /// 中介者
        /// </summary>
        private readonly IMediator mediator;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="mediator"></param>
        public ChronicCareController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 慢病诊疗记录的添加
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> AddChronicCareJL(AddChronicCareJLCommand request, CancellationToken cancellationToken)
        {
            try
            {

                 return await mediator.Send(request, cancellationToken);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 慢病诊疗的就诊信息的添加
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> AddMedicalVisitInf(AddMedicalVisitInfoCommand request, CancellationToken cancellationToken)
        {
            try
            {
                 return await mediator.Send(request, cancellationToken);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 慢病诊疗的复诊计划信息的添加
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> AddFollowUpPlan(AddFollowUpPlanCommand request, CancellationToken cancellationToken)
        {
            try
            {
                return await mediator.Send(request, cancellationToken);
            }
            catch (Exception)
            {

                throw;
            }
        }

        /// <summary>
        /// 慢病诊疗的复诊计划信息的删除
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<APIResult<int>> DelFollowUpPlan(DelFollowUpPlanCommand request, CancellationToken cancellationToken)
        {
            try
            {
                return await mediator.Send(request, cancellationToken);
            }
            catch (Exception)
            {

                throw;
            }
        }




    }

}
